* wowomtb.p - WORK ORDER MAINT ALLOC COMPS, SCHED ROUT, MRP SUPPLY     */
/* Copyright 1986-2000 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/* REVISION: 7.0      LAST EDIT: 09/04/91      MODIFIED BY: pma *F003**/
/* REVISION: 7.0      LAST EDIT: 10/11/91      MODIFIED BY: emb *F024*/
/* REVISION: 6.0      LAST EDIT: 11/14/91      MODIFIED BY: WUG *D887*/
/* REVISION: 6.0      LAST EDIT: 12/04/91      MODIFIED BY: RAM *D958*/
/* REVISION: 7.3      LAST EDIT: 10/19/92      MODIFIED BY: emb *G208*/
/* REVISION: 7.2      LAST EDIT: 09/27/92      MODIFIED BY: jcd *G247*/
/* REVISION: 7.3      LAST EDIT: 11/02/92      MODIFIED BY: emb *G268*/
/* REVISION: 7.3      LAST EDIT: 02/08/93      MODIFIED BY: emb *G656*/
/* REVISION: 7.3      LAST EDIT: 03/25/93      MODIFIED BY: emb *G870*/
/* REVISION: 7.3      LAST EDIT: 02/15/94      MODIFIED BY: pxd *FL60*/
/* REVISION: 7.2      LAST EDIT: 07/11/94      MODIFIED BY: ais *FO71*/
/* REVISION: 7.2      LAST EDIT: 09/01/94      MODIFIED BY: ljm *FQ67*/
/* Oracle changes (share-locks)  09/13/94      MODIFIED BY: rwl *GM56*/
/* REVISION: 8.5      LAST EDIT: 10/17/94      MODIFIED BY: tjs *J027*/
/* REVISION: 7.2      LAST EDIT: 01/18/95      MODIFIED BY: ais *F0F2*/
/* REVISION: 8.5      LAST EDIT: 11/20/95      MODIFIED BY: tjs *J09D*/
/* REVISION: 7.3      LAST EDIT: 04/16/96      MODIFIED BY: rvw *G1T2*/
/* REVISION: 8.5      LAST EDIT: 07/26/96      MODIFIED BY: jxz *J11X*/
/* REVISION: 8.5      LAST MODIFIED: 09/29/97  BY: *J1PS* Felcy D'Souza */
/* REVISION: 8.5      LAST MODIFIED: 12/20/97  BY: *H1HK* Felcy D'Souza */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan   */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KC* Mark Brown    */
/* REVISION: 9.1      LAST MODIFIED: 10/16/00   BY: *N0SX* Jean Miller   */
/* REVISION: 9.1      LAST MODIFIED: 11/06/00   BY: *N0TN* Jean Miller    */
/*************************************************************************/

         {mfdeclre.i}
/*N0SX*/ {gplabel.i}
/* ********** Begin Translatable Strings Definitions ********* */
/*N0SX* &SCOPED-DEFINE wowomtb_p_1 "Work Order Component" */
/* MaxLen: Comment: */
/*N0SX* &SCOPED-DEFINE wowomtb_p_2 "Work Order" */
/* MaxLen: Comment: */
/*N0SX* &SCOPED-DEFINE wowomtb_p_3 "Scrap Requirement" */
/* MaxLen: Comment: */
/*N0SX* &SCOPED-DEFINE wowomtb_p_4 "Repetitive Schedule" */
/* MaxLen: Comment: */
/* ********** End Translatable Strings Definitions ********* */
/*G247*  define shared variable mfguser as character. */
         define shared variable comp like ps_comp.
         define shared variable qty like wo_qty_ord.
         define shared variable eff_date as date.
         define shared variable wo_recno as recid.
         define shared variable leadtime like pt_mfg_lead.
         define shared variable prev_status like wo_status.
         define shared variable prev_release like wo_rel_date.
         define shared variable prev_due like wo_due_date.
/*J11X /*J09D*/ define shared variable due_date like wo_due_date. */
         define shared variable prev_qty like wo_qty_ord.
         define shared variable del-yn like mfc_logical.
         define shared variable deliv like wod_deliver.
         define shared variable any_issued like mfc_logical.
/*H1HK** define variable i as integer.
 *       define variable nonwdays as integer.
 *       define variable overlap as integer.
 *       define variable workdays as integer.
 *       define variable interval as integer.
 *       define variable know_date as date.
 *       define variable find_date as date.
 * /*FQ67*  define variable forward as integer. */
 * /*FQ67*/ define variable frwrd as integer.
 *H1HK*/
/*H1HK*/ define variable i as integer no-undo.
         define variable open_ref like wo_qty_ord no-undo.
/*J11X /*J09D*/ define variable mrpqty like mrp_qty no-undo.          */
/*J11X /*J09D*/ define variable co_product_part like wo_part no-undo. */
/*J11X /*J09D*/ define variable date-string as character no-undo.     */
         define shared variable prev_site like wo_site.
/*D620*/ define shared variable ord_chg as decimal.
/*D629*/ define variable rpsnbr like mrp_nbr.
/*J1PS*/ define variable inrecno as recid no-undo.
/*J11X /*J09D*/ define buffer wo_mstr1 for wo_mstr. */
/*H1HK*  mfdatev.i DECLARES VARIABLES REQUIRED BY mfdate.i */
/*H1HK*/ {mfdatev.i}
/*G870*  find wo_mstr where recid(wo_mstr) = wo_recno. */
/*G870*/ find wo_mstr no-lock where recid(wo_mstr) = wo_recno.
         if index("PFCEAR",prev_status) > index("PFCEAR",wo_status)
         and index("PFCEAR",wo_status) > 0
         and index("EAR",prev_status) > 0
/*J027*/ and index("1234",wo_joint_type) = 0 then do:
/*J027*/    /* DELETE EXISTING wod_det AND THEIR ALLOCATIONS AND mrp_det */
/*J027*/    {gprun.i ""wowomtb1.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
/*J027******DELETED THE FOLLOWING SECTION. NOW IN wowomtb1.p *******************
         *
         *  for each wod_det where wod_lot = wo_lot:
         *     find pt_mstr where pt_part = wod_part no-lock no-error.
         *
         *     find ptp_det no-lock where ptp_part = wod_part
         *     and ptp_site = wod_site no-error.
         *
         *     find in_mstr where in_part = wod_part and in_site = wod_site
         *     exclusive no-error.
         *
         *     if index("PC",wo_status) > 0 and available in_mstr then do:
         *        if wod_qty_req >= 0 then
         *           in_qty_req = in_qty_req - max(wod_qty_req - wod_qty_iss,0).
         *        else
         *           in_qty_req = in_qty_req - min(wod_qty_req - wod_qty_iss,0).
         *        in_qty_all = in_qty_all - wod_qty_all - wod_qty_pick.
         *
/*GM56*/ *        for each lad_det exclusive where lad_dataset = "wod_det"
/*G656*  *        and lad_nbr = wod_nbr and lad_line = wod_lot */
/*G656*/ *        and lad_nbr = wod_lot and lad_line = string(wod_op)
         *        and lad_part = wod_part:
         *           find ld_det exclusive where ld_site = lad_site
         *           and ld_loc = lad_loc and ld_lot = lad_lot
         *           and ld_part = lad_part and ld_ref = lad_ref no-error.
         *           if available ld_det then
         *              ld_qty_all = ld_qty_all - (lad_qty_all + lad_qty_pick).
/*F0F2*/ *           {mflddel.i}
         *           delete lad_det.
         *        end.
         *     end.
         *     if index("PF",wo_status) > 0 then do:
         *        wod_qty_all = 0.
         *        wod_qty_pick = 0.
         *        if (available ptp_det and ptp_iss_pol = no)
         *        or (not available ptp_det
         *           and available pt_mstr and pt_iss_pol = no)
         *        then wod_qty_iss = 0.
         *     end.
         *
         *     if wo_status = "C" then
         *        assign wod_qty_all = 0
         *              wod_qty_pick = 0.
         *
         *     if wo_status = "A" then do:
/*GM56*/ *        for each lad_det exclusive where lad_dataset = "wod_det"
/*G656*  *        and lad_nbr = wod_nbr and lad_line = wod_lot */
/*G656*/ *        and lad_nbr = wod_lot and lad_line = string(wod_op)
         *        and lad_part = wod_part:
         *           lad_qty_all = lad_qty_all + lad_qty_pick.
         *           lad_qty_pick = 0.
         *        end.
         *        wod_qty_all = wod_qty_all + wod_qty_pick.
         *        wod_qty_pick = 0.
         *     end.
         *
         *     if wo_status = "E" then do:
         *        if available in_mstr then
         *           in_qty_all = in_qty_all - wod_qty_all - wod_qty_pick.
         *        if (available ptp_det and ptp_iss_pol = no)
         *        or (not available ptp_det
         *        and available pt_mstr and pt_iss_pol = no)
/*FO71*  *        then wod_qty_iss = 0.                               */
/*FO71*/ *        then do:
/*FO71*/ *           if wod_qty_iss <> 0
/*FO71*/ *           then do:
/*FO71*/ *              wod_qty_iss = 0.
/*FO71*/ *              if index("ARC",prev_status) <> 0
/*FO71*/ *              then if available in_mstr
/*FO71*/ *              then in_qty_req = in_qty_req + wod_qty_req.
/*FO71*/ *           end.
/*FO71*/ *        end.
         *
         *        wod_qty_all = 0.
         *        wod_qty_pick = 0.
         *
/*GM56*/ *        for each lad_det exclusive where lad_dataset = "wod_det"
/*G656*  *        and lad_nbr = wod_nbr and lad_line = wod_lot */
/*G656*/ *        and lad_nbr = wod_lot and lad_line = string(wod_op)
         *        and lad_part = wod_part:
         *           find ld_det exclusive where ld_site = lad_site
         *           and ld_loc = lad_loc and ld_lot = lad_lot
         *           and ld_part = lad_part and ld_ref = lad_ref no-error.
         *           if available ld_det then
         *              ld_qty_all = ld_qty_all - (lad_qty_all + lad_qty_pick).
/*F0F2*/ *           {mflddel.i}
         *           delete lad_det.
         *        end.
         *     end.
         *  end.
 *J027******/
         end. /* if index("PFCEAR",prev_status) > index("PFCEAR",wo_status)*/
/*G1T2*/ if ((prev_due <> wo_due_date and index("EAR",wo_status) > 0)
/*H1HK** /*G1T2*/ or ord_chg <> 1 or wo_rel_date = ?) */
/*H1HK*/          or ord_chg <> 1 or wo_rel_date = ? or wo_due_date = ?)
/*G1T2*/     and index("1234",wo_joint_type)= 0
/*G1T2*/ then do:
/*G1T2*/    /* SCHEDULE OPERATION START AND DUE DATES */
/*G1T2*/    {gprun.i ""woworle.p""}
/*GUI*/ if global-beam-me-up then undo, leave.
/*G1T2*/ end.
/*G268*  if prev_release <> wo_rel_date and wo_status <> "C"
      *  then do: */
/*J027*/ if index("1234",wo_joint_type) = 0 then do:
            for each wod_det where wod_lot = wo_lot
            and wod_nbr = wo_nbr:
/*GUI*/ if global-beam-me-up then undo, leave.            
/*G268*/       if wo_rel_date <> prev_release then do:
                  if wod_iss_date <> prev_release then do:
                     {mfwday.i prev_release wod_iss_date workdays wod_site}
                     if wod_iss_date < prev_release
                        then workdays = workdays * -1.
                     wod_iss_date = ?.
                     {mfdate.i wo_rel_date wod_iss_date workdays wod_site}
                  end.
                  else wod_iss_date = wo_rel_date.
/*G268*/       end.
/*G268**       open_ref = max(wod_qty_req - wod_qty_iss,0).
       *       if wod_qty_req < 0
       *          then open_ref = min(wod_qty_req - wod_qty_iss,0). */
/*G268*/       if wod_qty_req >= 0
/*G268*/       then open_ref = max(wod_qty_req - max(wod_qty_iss,0),0).
/*G268*/       else open_ref = min(wod_qty_req - min(wod_qty_iss,0),0).
/*G268*/       if wo_status = "C" then open_ref = 0.
               /* work order components */
/*G208**       {mfmrw.i "wod_det" wod_part wod_nbr wod_lot """" ? wod_iss_date
       *       open_ref "DEMAND" "Work Order Component" wod_site} */
/*G208*/       {mfmrwdel.i "wod_det" wod_part wod_nbr wod_lot """"}
/*N0TN*/       /* Replaced pre-processor with Term in include */
/*G208*/       {mfmrw.i "wod_det" wod_part wod_nbr wod_lot string(wod_op)
               ? wod_iss_date open_ref "DEMAND" WORK_ORDER_COMPONENT wod_site}
            end.
/*GUI*/ if global-beam-me-up then undo, leave.            
/*J027*/ end.
/*G268*  end. */
/*G1T2*  FOLLOWING CODE MOVED ABOVE
./*J027*  if (prev_due <> wo_due_date and index("EAR",wo_status) > 0)  */
./*J027*  or ord_chg <> 1                                              */
./*J027*/  if ((prev_due <> wo_due_date and index("EAR",wo_status) > 0)
./*J027*/      or ord_chg <> 1) and index("1234",wo_joint_type) = 0
.        then do:
.           /* schedule operation start and due dates */
.           {gprun.i ""woworle.p""}
.        end.
.*G1T2*  END OF MOVED CODE                    */
         /* work order */
         if index("C",wo_status) = 0 then do:
            open_ref = max(wo_qty_ord - wo_qty_comp - wo_qty_rjct,0).
            if wo_qty_ord < 0 then
               open_ref = min(wo_qty_ord - wo_qty_comp - wo_qty_rjct,0).
/*N0TN*/    /* Replaced pre-processor with Term in include */
            {mfmrw.i "wo_mstr" wo_part wo_nbr wo_lot """"
             wo_rel_date wo_due_date "open_ref" "SUPPLY" WORK_ORDER wo_site}
            if available mrp_det and index("FBE",wo_status) > 0
               then mrp_type = "SUPPLYF".
/*G870*/    if available mrp_det and wo_status = "P"
/*G870*/       then mrp_type = "SUPPLYP".
/*J11X*/ /* Backout the following logic which was implemented by ECO J09D */
/*J11X***********Begin of Deletion****************************
/*J09D*/ *  /* Begin added block */
         *  /* SYCNRONIZE BASE PROCESS MRP DEMAND WITH SUPPLY */
         *  if wo_joint_type = "5" and
         *  (prev_due <> wo_due_date or prev_qty <> wo_qty_ord) then do:
         *     {dateconv.i prev_due date-string}
         *     /* FIND THE BASE WO's DEMAND RECORD */
         *     /* Primary key are these fields plus mrp_nbr = co-product part#*/
         *     find first mrp_det exclusive-lock where
         *     mrp_dataset = "jp_det" and mrp_part  = wo_part and
         *     mrp_line    = wo_site  and mrp_line2 = date-string no-error.
         *
         *     /* ADJUST QTY - mrp_det IS SHARED W/ OTHER WOs W/SAME DUEDATE */
         *     if available mrp_det then do:
         *        co_product_part = mrp_nbr.
         *        if wo_due_date <> prev_due then
         *           /* REMOVE DEMAND FOR OLD DUEDATE */
         *           mrpqty = maximum(0,(mrp_qty - prev_qty)).
         *        else
         *           /* ADJUST DEMAND QTY */
         *           mrpqty = maximum(0,mrp_qty + (wo_qty_ord - prev_qty)).
         *        {mfmrw.i "jp_det" wo_part co_product_part wo_site
         *         date-string ? prev_due mrpqty "DEMAND" """" wo_site}
         *     end.
         *     /* NEW mrp_det */
         *     if not available mrp_det or wo_due_date <> prev_due then
         *     do for wo_mstr1:
         *        /* GET THE BASE WO's 1st CO-PRODUCT WO FOR CO-PRODUCT PART# */
         *        find first wo_mstr1 no-lock where
         *        wo_mstr1.wo_nbr = wo_mstr.wo_nbr and
         *        wo_mstr1.wo_joint_type = "1" no-error.
         *        if available wo_mstr1 then co_product_part = wo_mstr1.wo_part.
         *        mrpqty = wo_mstr.wo_qty_ord.
         *        {dateconv.i wo_due_date date-string}
         *        {mfmrw.i "jp_det" wo_mstr.wo_part co_product_part
         *         wo_mstr.wo_site date-string ? wo_mstr.wo_due_date
         *         mrpqty "DEMAND" """" wo_mstr.wo_site "+ co_product_part"}
         *     end.
         *  end.
/*J09D*/ *  /* End added block */
**J11X***************End of Deletion ************************/
/*N0TN*/    /* Replaced pre-processor with Term in include */
            {mfmrw.i "wo_scrap" wo_part wo_nbr wo_lot """"
             wo_rel_date wo_due_date "open_ref * (1 - wo_yield_pct / 100)"
            "DEMAND" SCRAP_REQUIREMENT wo_site}
         end.
         else do:
            /* CLOSED - DELETE MRP DETAIL */
            for each wod_det where wod_lot = wo_lot no-lock:
/*GUI*/ if global-beam-me-up then undo, leave.            
               /* work order components */
               {mfmrwdel.i "wod_det" wod_part wod_nbr wod_lot """"}
/*G208*/       {mfmrwdel.i "wod_det" wod_part wod_nbr wod_lot string(wod_op)}
/*G870*        {mfmrp.i wod_part "yes"} /* UPDATE ITEM MASTER MRP FLAG */ */
/*G870*/       {inmrp.i &part=wod_part &site=wod_site}
            end.
/*GUI*/ if global-beam-me-up then undo, leave.            
/*N0TN*/    /* Replaced pre-processor with Term in include */
            {mfmrw.i "wo_mstr" wo_part wo_nbr wo_lot """"
             wo_rel_date wo_due_date "0" "SUPPLY" WORK_ORDER wo_site}
/*J11X*/ /* Backout the following logic which was implemented by ECO J09D */
/*J11X***********Begin of Deletion****************************
/*J09D*/ *  /* Begin added block */
         *  if wo_joint_type = "5" then do:
         *     /* FIND THE BASE WO's DEMAND RECORD */
         *     {dateconv.i prev_due date-string}
         *     /* Primary key are these fields plus mrp_nbr = co-product part#*/
         *     find first mrp_det exclusive-lock where
         *     mrp_dataset = "jp_det" and mrp_part  = wo_part and
         *     mrp_line    = wo_site  and mrp_line2 = date-string no-error.
         *     /* ADJUST QTY - mrp_det IS SHARED W/ OTHER WOs W/SAME DUEDATE */
         *     if available mrp_det then do:
         *        co_product_part = mrp_nbr.
         *        mrpqty = maximum(0,(mrp_qty - prev_qty)).
         *        {mfmrw.i "jp_det" wo_part co_product_part wo_site
         *         date-string ? prev_due mrpqty "DEMAND" """" wo_site}
         *     end.
         *  end.
/*J09D*/ * /* End added block */
**J11X***************End of Deletion ************************/
/*N0TN*/    /* Replaced pre-processor with Term in include */
            {mfmrw.i "wo_scrap" wo_part wo_nbr wo_lot """"
             wo_rel_date wo_due_date "0" "DEMAND" SCRAP_REQUIREMENT wo_site}
         end.
         if (index("PBFC",prev_status) > 0 and index("EAR",wo_status) > 0)
         or (index("EAR",prev_status) > 0 and index("BFC",wo_status) > 0)
         or (index("EAR",prev_status) > 0 and index("EAR",wo_status) > 0
             and prev_qty <> wo_qty_ord)
         or prev_site <> wo_site
         then do:
            if lookup(prev_status,"E,A,R") > 0 then do:
               find in_mstr where in_part = wo_part and in_site = prev_site
               exclusive-lock no-error.
               if available in_mstr then do:
                  if prev_qty >= 0 then
                     in_qty_ord = in_qty_ord -
                     max(prev_qty - wo_qty_comp - wo_qty_rjct,0).
                  else in_qty_ord = in_qty_ord -
                     min(prev_qty - wo_qty_comp - wo_qty_rjct,0).
               end.
            end.
            if lookup(wo_status,"E,A,R") > 0 then do:
/*J1PS** BEGIN DELETE */
/*J1PS*  FOLLOWING CODE IS COMMENTED OUT SINCE GPINCR.P ROUTINE IS USED */
/*       IN THE CREATION OF IN_MSTR RECORD. ALSO, IN_MSTR RECORD IS     */
/*       FOUND IN GPINCR.P ROUTINE BEFORE THE CREATION.                 */
/*J1PS**       find in_mstr where in_part = wo_part and in_site = wo_site
 *               exclusive-lock no-error.
 *               if not available in_mstr then do:
 *             create in_mstr.
 *                  assign
 *                  in_part = wo_part
 *                  in_site = wo_site.
 * /*FL60*/       in_level = 99999.
 *J1PS** END DELETE */
/*FL60            find ptp_det no-lock where ptp_part = in_part
*                 and ptp_site = in_site no-error.
*                 if available ptp_det then do:
*                    if ptp_pm_code = "D"
*                    then in_level = ptp_ll_drp.
*                    else in_level = ptp_ll_bom.
*                 end.
*                 else if pt_pm_code <> "D"
*                    then in_level = pt_ll_code.          FL60*/
/*J1PS** BEGIN DELETE */
/*J1PS** FOLLOWING CODE IS COMMENTED OUT SINCE SI_MSTR AND PT_MSTR VALUES */
/*       ARE PASSED TO GPINCR.P ROUTINE WHICH WILL BE USED DURING THE     */
/*       CREATION OF IN_MSTR.                                             */
/*J1PS** /*F003*/ find si_mstr where si_site = in_site no-lock no-error.
 * /*F003*/          if available si_mstr
 * /*F003*/             then assign in_gl_set = si_gl_set
 *                               in_cur_set = si_cur_set.
 * /*F003*/          find pt_mstr where pt_part = wo_part no-lock no-error.
 * /*F003*/          if available pt_mstr
 * /*F003*/             then assign in_abc          = pt_abc
 * /*F003*/                         in_avg_int      = pt_avg_int
 * /*F003*/                         in_cyc_int      = pt_cyc_int.
 *       end. /*IF NOT AVAILABLE in_mstr */
 *J1PS** END DELETE */
/*J1PS*  BEGIN OF ADDED CODE */
/*J1PS*  gpincr.p ROUTINE IS USED TO CREATE in_mstr RECORD. */
                find si_mstr where si_site = wo_site no-lock no-error.
                find pt_mstr where pt_part = wo_part no-lock no-error.
                {gprun.i ""gpincr.p"" "(input no,
                                        input wo_part,
                                        input wo_site,
                                        input if available si_mstr then
                                                  si_gl_set
                                              else """",
                                        input if available si_mstr then
                                                  si_cur_set
                                              else """",
                                        input if available pt_mstr then
                                                  pt_abc
                                              else """",
                                        input if available pt_mstr then
                                                  pt_avg_int
                                              else 0,
                                        input if available pt_mstr then
                                                  pt_cyc_int
                                              else 0,
                                        input if available pt_mstr then
                                                  pt_rctpo_status
                                              else """",
                                        input if available pt_mstr then
                                                  pt_rctpo_active
                                              else no,
                                        input if available pt_mstr then
                                                  pt_rctwo_status
                                              else """",
                                        input if available pt_mstr then
                                                  pt_rctwo_active
                                              else no,
                                        output inrecno)" }
/*GUI*/ if global-beam-me-up then undo, leave.                                        
                find in_mstr where recid(in_mstr) = inrecno
                exclusive-lock.
/*J1PS*  END OF ADDED CODE */
               if wo_qty_ord >= 0 then
                  in_qty_ord = in_qty_ord +
                  max(wo_qty_ord - wo_qty_comp - wo_qty_rjct,0).
               else in_qty_ord = in_qty_ord +
                  min(wo_qty_ord - wo_qty_comp - wo_qty_rjct,0).
            end.
         end.
         if wo_type = "S"
         and index("BPFEARC",prev_status) < index("PBFEARC",wo_status)
         then do:
/*G870*/    find wo_mstr exclusive-lock where recid(wo_mstr) = wo_recno.
            find rps_mstr exclusive-lock where rps_record = integer(wo_lot)
            no-error.
            if available rps_mstr then do:
               rps_qty_req = max(rps_qty_req
                  - max(wo_qty_ord - wo_qty_comp - wo_qty_rjct,0),0).
               {dateconv.i rps_due_date rpsnbr}
               rpsnbr = rpsnbr + rps_site.
/*N0TN*/    /* Replaced pre-processor with Term in include */
               {mfmrw.i "rps_mstr" rps_part rpsnbr string(rps_record) """"
               rps_rel_date rps_due_date "max(rps_qty_req - rps_qty_comp,0)"
               "SUPPLYF" REPETITIVE_SCHEDULE rps_site}
               if rps_qty_req = 0 and rps_qty_comp = 0 then delete rps_mstr.
            end.
            wo_type = "".
         end.
      